﻿<phone:PhoneApplicationPage 
    x:Class="MoAds.Example.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:moad="clr-namespace:MoAds;assembly=MoAds" 
    xmlns:adadapters="clr-namespace:MoAds.AdAdapters;assembly=MoAds"
    xmlns:admob="clr-namespace:MoAds.AdAdapters.AdMob;assembly=MoAds"
    xmlns:zestadz="clr-namespace:MoAds.AdAdapters.ZestAdz;assembly=MoAds"
    xmlns:millennialmedia="clr-namespace:MoAds.AdAdapters.MillennialMedia;assembly=MoAds"
    xmlns:local="clr-namespace:MoAds.Example"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>


        <Style x:Key="TextOnlyAdMobStyle" TargetType="moad:AdDisplayControl">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="18" />
            <Setter Property="Width" Value="480"/>
            <Setter Property="Height" Value="70"/>
            <Setter Property="Background" Value="#FF1F1F1F"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="moad:AdDisplayControl">
                        <Grid
							x:Name="PART_AdRoot"
							Height="{TemplateBinding Height}"
							Width="{TemplateBinding Width}">
                            <Grid.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF4E4E4E" Offset="0.078"/>
                                    <GradientStop Color="#FF080404" Offset="0.935"/>
                                </LinearGradientBrush>
                            </Grid.Background>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="2*" />
                                <ColumnDefinition Width="6*" />
                                <ColumnDefinition Width="2*" />
                            </Grid.ColumnDefinitions>

                            <Border
								Visibility="Collapsed"
								Background="Transparent"
								x:Name="AdImageHolder"  
								HorizontalAlignment="Stretch"
								VerticalAlignment="Stretch"
								Grid.Column="0">
                                <Image 
									x:Name="PART_AdImage"
									Margin="15 10"
									Source="{TemplateBinding LoadedAdImageUri}" 
									Stretch="Fill"									
									HorizontalAlignment="Stretch" 
									VerticalAlignment="Stretch"/>
                            </Border>

                            <TextBlock
								Margin="3"
								x:Name="PART_AdText"
								Grid.Column="0"
								Grid.ColumnSpan="3"								
								FontSize="{TemplateBinding FontSize}"
								VerticalAlignment="Center"
								HorizontalAlignment="Center"
								TextWrapping="Wrap"
								Foreground="#F64F4FFD"
								Text="{TemplateBinding LoadedAdText}"/>

                            <Border
								x:Name="AdGoHolder"                            
								Grid.Column="2">
                                <Button
									Visibility="Collapsed"
									Margin="15 10"
									x:Name="PART_AdGo"									
									HorizontalAlignment="Stretch"
									VerticalAlignment="Stretch">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Image
												Source="/MoAds;component/Themes/go.png"
												HorizontalAlignment="Stretch"
												VerticalAlignment="Stretch"
												Stretch="Fill"/>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="AnimationAdMobStyle" TargetType="moad:AdDisplayControl">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="18" />
            <Setter Property="Width" Value="480"/>
            <Setter Property="Height" Value="70"/>
            <Setter Property="Background" Value="#FF1F1F1F"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="moad:AdDisplayControl">
                        <Grid
							x:Name="PART_AdRoot"
							Height="{TemplateBinding Height}"
							Width="{TemplateBinding Width}">
                            <Grid.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF252525" Offset="0.103"/>
                                    <GradientStop Color="#F6010108" Offset="0.832"/>
                                </LinearGradientBrush>
                            </Grid.Background>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="2*" />
                                <ColumnDefinition Width="6*" />
                                <ColumnDefinition Width="2*" />
                            </Grid.ColumnDefinitions>

                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="VisualStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="Loading" GeneratedDuration="0" To="Normal">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_AdRoot">
                                                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="1"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition GeneratedDuration="0" To="Loading">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames FillBehavior="HoldEnd" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_AdRoot">
                                                    <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Error"/>
                                    <VisualState x:Name="Loading">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_AdRoot" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>

                            <Border
								Background="Transparent"
								x:Name="AdImageHolder"  
								HorizontalAlignment="Stretch"
								VerticalAlignment="Stretch"
								Grid.Column="0">
                                <Image 
									x:Name="PART_AdImage"
									Margin="15 10"
									Source="{TemplateBinding LoadedAdImageUri}" 
									Stretch="Fill"
									HorizontalAlignment="Stretch" 
									VerticalAlignment="Stretch"/>
                            </Border>

                            <TextBlock
								Margin="3"
								x:Name="PART_AdText"
								Grid.Column="1"
								FontSize="{TemplateBinding FontSize}"
								VerticalAlignment="Center"
								HorizontalAlignment="Center"
								TextWrapping="Wrap"
								Foreground="{TemplateBinding Foreground}"
								Text="{TemplateBinding LoadedAdText}"/>

                            <Border
								x:Name="AdGoHolder"                            
								Grid.Column="2">
                                <Button
									Margin="15 10"
									x:Name="PART_AdGo"
									HorizontalAlignment="Stretch"
									VerticalAlignment="Stretch">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Image
												Source="/MoAds;component/Themes/go.png"
												HorizontalAlignment="Stretch"
												VerticalAlignment="Stretch"
												Stretch="Fill"/>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>



    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
            <TextBlock x:Name="ApplicationTitle" Text="MO ADS" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="examples" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1">

            <!-- TODO: The example won't work until you put a publisher id in. -->
            <!-- Get your own publisher id from www.admob.com -->
            
            <!-- Default template example -->
            <moad:AdDisplayControl
                Style="{StaticResource AnimationAdMobStyle}" 
                Height="70"
                VerticalAlignment="Top"
                Foreground="White"
                RefreshSeconds="5">
                <moad:AdDisplayControl.AdAdapters>
                    <adadapters:AdAdapterCollection>
                        <local:CustomAdAdapter
                            Priority="0"
                            AdCount="2"
                            PublisherId="SomePubId"
                            ClientId="SomeClientId"/>
<!--
                        <admob:AdMobAdapter 
                            Priority="1"
                            AdCount="3"
                            UseTestMode="True"
                            PublisherId="YourPublisherId" 
                            CookieString="YourCookieString" 
                            AdKeywords="Boston" />
                        
                        <zestadz:ZestAdzAdapter 
                            AdCount="1" 
                            AdKeywords="Boston" 
                            ClientId="YourSiteId" 
                            MetaData="" AdsPerRequest="3" />
                        -->
                        <millennialmedia:MillennialMediaAdapter 
                            AdCount="1"  
                            PlacementId="YourPlacementId" 
                            Mode="test"/>
                    </adadapters:AdAdapterCollection>
                </moad:AdDisplayControl.AdAdapters>
            </moad:AdDisplayControl>

            <!-- Simple Custom Style example -->
            <!--<moad:AdDisplay
                Style="{StaticResource TextOnlyAdMobStyle}"                
                VerticalAlignment="Center"                
                Foreground="White"
                RefreshSeconds="30">
                <moad:AdDisplay.AdAdapter>
                    <admob:AdMobAdapter
                        PublisherId="YourPublisherID"
                        CookieString="YourCookieString"
                        AdKeywords="Boston"
                        UseTestMode="True"/>
                </moad:AdDisplay.AdAdapter>
            </moad:AdDisplay>-->

            <!-- Animation style example -->
            <!--<moad:AdDisplay
                Style="{StaticResource AnimationAdMobStyle}"                
                VerticalAlignment="Bottom"
                Foreground="White"
                RefreshSeconds="30">
                <moad:AdDisplay.AdAdapter>
                    <moad:AdMobAdapter
                        PublisherId="YourPublisherID"
                        CookieString="YourCookieString"
                        AdKeywords="Boston"
                        UseTestMode="True"/>
                </moad:AdDisplay.AdAdapter>
            </moad:AdDisplay>-->

            <!-- Custom Ad Service example 
            <moad:AdDisplayControl
                Style="{StaticResource AnimationAdMobStyle}"                
                VerticalAlignment="Bottom"
                Foreground="White"
                RefreshSeconds="5">
                <moad:AdDisplayControl.AdAdapters>
                    <adadapters:AdAdapterCollection>
                        <admob:AdMobAdapter 
                            UseTestMode="True"
                            PublisherId="a14c88989363857" 
                            CookieString="YourCookieString" 
                            AdKeywords="Boston" />
                    </adadapters:AdAdapterCollection>
                </moad:AdDisplayControl.AdAdapters>
            </moad:AdDisplayControl>-->

        </Grid>
    </Grid>

    <!-- Sample code showing usage of ApplicationBar
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"></shell:ApplicationBarIconButton>
            <shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"></shell:ApplicationBarIconButton>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem>
                <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    -->


</phone:PhoneApplicationPage>
